package com.example.viewpageapplication.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.viewpageapplication.fragment.DynamicFragment;

public class DyFragmentAdapter extends FragmentPagerAdapter {

    private final int[] mImageArray;
    public DyFragmentAdapter(@NonNull FragmentManager fm, int[] mImageArray) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.mImageArray = mImageArray;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return DynamicFragment.newInstance(position,mImageArray[position],mImageArray.length);
    }

    @Override
    public int getCount() {
        return mImageArray.length;
    }
}
